fix: remove If-Match header and stop clearing storage on 412#139
fix: remove If-Match header and stop clearing storage on 412#139kptdobe wants to merge 1 commit into
Conversation
|
I think the If-Match header was added to fix a specific issue: b33ae65 @karlpauls could you please review? |
The If-Match: * header on PUT requests caused da-admin to return 412 whenever the document did not yet exist (new document, or first write after DO cold-start). The 412 handler then called storage.deleteAll() and closed all WebSocket connections, destroying the entire Yjs state including images that had not yet been flushed to da-admin. Remove If-Match: * entirely — da-admin should always accept a PUT from collab whether the resource exists or not. On any non-2xx response, show an error on the ydoc but do not touch storage or close connections; only 401/403 still trigger session termination. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
e6e9fe6 to
c728a3b
Compare
Closing — root cause is in da-admin, not da-collabAfter deeper analysis, the root cause of the image loss is a bug in da-admin's What actually happensWhen da-collab sends At that point da-admin has two paths:
The second path conflates The fixda-admin PR to follow — da-collab: no changes needed. |
Problem
persistence.putsentIf-Match: *on every PUT to da-admin. This header tells da-admin "only apply this write if the resource already exists." When the document didn't exist yet (new document, DO cold-start before the first successful write), da-admin returned 412 Precondition Failed.The 412 handler then:
ydoc.storage.deleteAll()— destroying the entire Yjs state, including images not yet flushed to da-adminThis was the chain that caused inserted images to permanently disappear.
Root cause
If-Match: *has no useful purpose in the collab context:syncadmin/deleteadminAPIs are the correct mechanism for coordinating external changesSolution
If-Match: *frompersistence.put— da-admin now always accepts PUT unconditionallyTests
If-Matchheader is absent on PUT; 412 does NOT clear storage or close connectionsTest persistence update shows error but preserves state on 412replaces the old "closes all and cleans storage" testIf-Match: *assertions replaced withnullassertions🤖 Generated with Claude Code